package card;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardDemo {
    private String[] suits = {"♥","♠","♦","♣"};
    public List<Card> buyCard() {
        List<Card> list = new ArrayList<>();

        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                Card card = new Card(suits[i], j);
                list.add(card);
            }
        }
        return list;
    }
    public void dislocate(List<Card> cardList) {
        Random random = new Random();
        for (int i = cardList.size()-1; i > 0 ; i--) {
            int rand = random.nextInt(i);
            swap(cardList,i,rand);
        }

    }
    public static void swap(List<Card> cardList,int x,int y) {
        Card tmp = cardList.get(x);
        cardList.set(x,cardList.get(y));
        cardList.set(y,tmp);
    }
    public void Inauguration(List<Card> cardList) {
        List<List<Card>> roles = new ArrayList<>();
        List<Card> role1 = new ArrayList<>();
        List<Card> role2 = new ArrayList<>();
        List<Card> role3 = new ArrayList<>();
        roles.add(role1);
        roles.add(role2);
        roles.add(role3);
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cardList.get(0);
                roles.get(j).add(card);
                cardList.remove(0);
            }
        }
        System.out.println("第一个人的牌");
        System.out.println(roles.get(0));
        System.out.println("第二个人的牌");
        System.out.println(roles.get(1));
        System.out.println("第三个人的牌");
        System.out.println(roles.get(2));

        System.out.println("剩余的牌");
        System.out.println(cardList);
    }
}


